package practice_02;

public class Fighting {
    public static void main(String[] args) throws InterruptedException {
        fighting(Roles.getOneRole(0), Roles.getOneRole(1));
    }

    public static void fighting(Role role1, Role role2) throws InterruptedException {
        System.out.println("创建角色ing...");
        Thread.sleep(500);
        System.out.println("\t角色\t\tHP\t\t攻击力\t技能1\t技能2");
        System.out.println("\t" + role1.getName() + "\t" + role1.getHp() + "\t" + role1.getAttack() + "\t\t" +
                role1.getRole_skills().getSkills()[0].getSkill_name() + "\t\t" +
                role1.getRole_skills().getSkills()[1].getSkill_name());
        Thread.sleep(500);
        System.out.println("\t" + role2.getName() + "\t" + role2.getHp() + "\t" + role2.getAttack() + "\t\t" +
                role2.getRole_skills().getSkills()[0].getSkill_name() + "\t" +
                role2.getRole_skills().getSkills()[1].getSkill_name());
        boolean flag = true;
        while (true) {
            if (flag) {
                Thread.sleep(800);
                role1.attack(role2);
                flag = false;
                if (role2.getHp() == 0) {
                    Thread.sleep(300);
                    System.out.println(role1.getName() + " 击败了 " + role2.getName());
                    break;
                }
            } else {
                Thread.sleep(800);
                role2.attack(role1);
                flag = true;
                if (role1.getHp() == 0) {
                    Thread.sleep(300);
                    System.out.println(role2.getName() + " 击败了 " + role1.getName());
                    break;
                }
            }
        }
        System.out.println("Game Over");
    }
}
